/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author sky
 */
@Entity
@Table(name = "SONG_PLAY_LIST", catalog = "", schema = "RADIO")
@NamedQueries({
    @NamedQuery(name = "SongPlayList.findAll", query = "SELECT s FROM SongPlayList s"),
    @NamedQuery(name = "SongPlayList.findByPlayListId", query = "SELECT s FROM SongPlayList s WHERE s.songPlayListPK.playListId = :playListId"),
    @NamedQuery(name = "SongPlayList.findBySongId", query = "SELECT s FROM SongPlayList s WHERE s.songPlayListPK.songId = :songId")})
public class SongPlayList implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SongPlayListPK songPlayListPK;

    public SongPlayList() {
    }

    public SongPlayList(SongPlayListPK songPlayListPK) {
        this.songPlayListPK = songPlayListPK;
    }

    public SongPlayList(long playListId, long songId) {
        this.songPlayListPK = new SongPlayListPK(playListId, songId);
    }

    public SongPlayListPK getSongPlayListPK() {
        return songPlayListPK;
    }

    public void setSongPlayListPK(SongPlayListPK songPlayListPK) {
        this.songPlayListPK = songPlayListPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (songPlayListPK != null ? songPlayListPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SongPlayList)) {
            return false;
        }
        SongPlayList other = (SongPlayList) object;
        if ((this.songPlayListPK == null && other.songPlayListPK != null) || (this.songPlayListPK != null && !this.songPlayListPK.equals(other.songPlayListPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "radiostation.SongPlayList[ songPlayListPK=" + songPlayListPK + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
